package com.xs.designpattern;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author xs
 */
public class Oliphaunt {
    private static final AtomicInteger count = new AtomicInteger(0);

    private final int id;

    public Oliphaunt() {
        id = count.incrementAndGet();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
            Thread.currentThread().interrupt();
        }
    }

    public int getId() {
        return id;
    }

    @Override
    public String toString() {
        return String.format("巨人 id=%d", id);
    }
}
